function maxProfit(prices: number[]): number {
    let prev = prices[0];
    let res = 0;
    for (let val of prices) {
        res += Math.max(0, val - prev)
        prev = val;
    }
    return res;
};

for (let i in [1, 2, 3].keys()) {
    console.log(i, typeof i)
}